<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title>拖曳插件</title>
    <style>
    #divtest {
        width: 282px;
        border: solid 1px #ccc;
    }

    .drag {
        border: solid 1px #fff;
        background-color: Blue;
        color: #fff;
        cursor: move;
        width: 35px;
        padding: 20px;
        text-align: center;
    }
    </style>
    <script src="http://www.imooc.com/data/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="ui.js" type="text/javascript"></script>
</head>

<body>
    <div id="divtest">
        <div id="x" class="drag">沿x轴拖拽</div>
        <div id="y" class="drag">沿y轴拖拽</div>
    </div>
    <script type="text/javascript">
    $(function() {
        $("#x").draggable({ containment: "parent", axis: "x" })
        $("#y").draggable({ containment: "parent", axis: "y" })
    });
    </script>
</body>

</html>